//package com.example.firstproject.controller;
//
//
//import lombok.extern.slf4j.Slf4j;
//import org.apache.ibatis.annotations.Param;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.multipart.MultipartFile;
//
//import javax.servlet.http.HttpServletResponse;
//import java.io.*;
//import java.util.HashMap;
//import java.util.Map;
//@Slf4j
//@RestController
//@RequestMapping("/file")
//public class FileController {
//
//
//
//    @RequestMapping(value = "/upload",method = RequestMethod.POST)
//    public Map<String,Object> fileUpload(@RequestParam MultipartFile file){
//        log.debug("name ==> {}",file.getName());
//        log.debug("origin name ==> {}",file.getOriginalFilename());
//        Map<String,Object> retData = new HashMap<>();
//        retData.put("code",200);
//        retData.put("message","success");
//        return retData;
//    }
//
//
//    @RequestMapping(value = "/download",method = RequestMethod.GET)
//    public Map<String,Object> fileDownload(HttpServletResponse response) throws IOException{
//        Map<String,Object> retData = new HashMap<>();
//        File file = new File("C:\\Users\\何欣希\\Desktop\\数据库.txt");
//        response.reset();
//        response.setContentType("application/ocet-stream");
//        response.setCharacterEncoding("utf-8");
//        response.setContentLengthLong(file.length());
//        response.setHeader("content-Disposition","attachment;filename=数据库.txt");
//
//        BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
//        byte [] bytes = new byte[1024];
//
//        OutputStream os = response.getOutputStream();
//        int i = 0;
//        while ((i = bis.read(bytes)) != -1){
//            os.write(bytes,0,i);
//            os.flush();
//        }
//        retData.put("code",200);
//        retData.put("message","success");
//        return retData;
//    }
//}
//
